Introduction to Software Engineering, Second Edition by Ronald J. Leach
Author:Ronald J. Leach
Language: eng
Format: epub
would declare the type to be an unsigned int, since strings cannot have negative length. We must have a constructor function to initialize the contents of the string and we must have a function to display the contents on the appropriate output stream.
Note what we have not determined yet. There has been no mention of the null byte \0
to be used as a termination byte to indicate the end of the string; hence, another question arises as to whether that termination byte is to be counted as part of the string, thereby increasing its length by one.
Indeed, there is no requirement that the string should be implemented as a set of contiguous bytes. We could choose to follow the lead of many word processing programs
Software Design ◾ 183
(including the one in which this book is written) and use linked lists to chain together contiguous arrays of characters (and other objects, such as graphs and images, in the case of the word processor). Linked lists are especially suited to insertions and deletions of text and other objects within a word processing document. Other data organizations are possible.
The important point is that none of the decisions about the implementation organiza-
tion or details is relevant to the string object. What we need now is a determination of the attributes of the object and a set of possible values for each attribute. With such a determination, we can write the first attempt of a description of the class. Thus, the first attempt at the definition of a string object will probably have a definition something like the class string defined next. We will not worry about syntax at this point.
class String
Member functions:
int length;
int strlen( String s);
void display( String s);
Some problems arise here because we have not precisely determined the interface. The
constructor member function needs to have a size specified for the length of the string.
Other member functions will have to have their interfaces determined, also. Thus, we
might have to make a second iteration of the design of the class representing strings.
class String
Member functions:
int length;
String (char *arr); //terminated by \0
int strlen();
operator << ;
There are more iterations that need to be performed in order to have a complete definition of the interfaces of the String class. Of course, we still have to develop an implementation of the methods. We omit the details of the iteration for the class description at this point since this class is part of the standard library for the C++ language and nearly every other object-oriented programming language in common use.
4.8 OBJECT-ORIENTED DESIGN REPRESENTATIONS
In this section, we will present a simple object model for the medical device terminal concentrator software system described in Section 4.4. We will make no attempt to refine the object model and will keep it at the same high level that we used for the previous models using different design representations.
The representation is simple (at least at this point). We will use a rectangular box
to describe an object, with diamond-shaped boxes and line segments used to indicate
184 ◾ Introduction to Software Engineering
relationships between objects.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(27094)
Hello! Python by Anthony Briggs(25948)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(25285)
Kotlin in Action by Dmitry Jemerov(24393)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(23591)
Dependency Injection in .NET by Mark Seemann(23313)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(21944)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(20848)
Grails in Action by Glen Smith Peter Ledbrook(19869)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17072)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(16832)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(14464)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(12582)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(11865)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10650)
Hit Refresh by Satya Nadella(9236)
The Kubernetes Operator Framework Book by Michael Dame(8588)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8445)
Robo-Advisor with Python by Aki Ranin(8387)